package 笔试题.跟谁学;

import java.util.Scanner;

public class 基因序列数目 {
    static class Main {
        static char[] genArray;
        static int length;

        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            String one = sc.nextLine();
            String two = sc.nextLine();
            genArray = two.toCharArray();
            length = Integer.parseInt(one);
            int result = calculate(genArray, length);
            System.out.print(result);
        }

        public static int calculate(char[] genArray, int length) {
            int start = 0, end = 0, count = 0;
            while (start < length - 5) {
                if (genArray[start] == 'A' && isStart(start)) {
                    end = start + 3;
                    while (end < length - 2) {
                        if (genArray[end] == 'T' && isEnd(end) && (end - start + 3) % 3 == 0) {
                            count++;
                            start = end + 3;
                            break;
                        } else {
                            end++;
                        }
                    }
                } else {
                    start++;
                }
            }
            return count;
        }

        public static boolean isStart(int i) {
            if (i + 2 + 3 >= length) return false;
            String start = genArray[i] + genArray[i + 1] + genArray[i + 2] + "";
            if (start.equals("ATG")) return true;
            return false;
        }

        public static boolean isEnd(int i) {
            if (i + 2 >= length) return false;
            String end = genArray[i] + genArray[i + 1] + genArray[i + 2] + "";
            if (end.equals("TAA") || end.equals("TAG") || end.equals("TGA")) return true;
            return false;
        }
    }
}
